<?php
/**
 * FastApp.
 * 10/17/24
 * @Author 深色的海 (wx:deepsea_0024)
 * @Contact telegram:deepsea159 
 */

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateMessageTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('message', function (Blueprint $table) {
            $table->engine = 'Innodb';
            $table->comment('系统消息表');
            $table->bigIncrements('id')->comment('主键');
            $table->bigInteger('account_type')->nullable()->unsigned()->default(1);
            $table->tinyInteger('type')->nullable()->comment('消息类型')->unsigned()->default(1);
            $table->tinyInteger('object_type')->nullable()->comment('数据类型1链接2视频3分享4文章5路径')->unsigned()->default(1);
            $table->bigInteger('object_id')->nullable()->comment('关联数据')->unsigned()->default(0);
            $table->integer('sort')->nullable()->comment('排序')->unsigned()->default(0);
            $table->char('url')->nullable()->comment('链接');
            $table->json('title')->nullable()->comment('标题');
            $table->json('image')->nullable()->comment('封面');
            $table->json('desc')->nullable()->comment('描述');
            $table->json('content')->nullable()->comment('内容');
            $table->char('remark')->nullable()->comment('备注');
            $table->timestamps();
            $table->timestamp('deleted_at')->nullable();
        });
        Schema::create('message_read', function (Blueprint $table) {
            $table->engine = 'Innodb';
            $table->comment('系统消息已读表');
            $table->bigIncrements('id')->comment('主键');
            $table->bigInteger('user_id')->unsigned()->default(0);
            $table->tinyInteger('type')->unsigned()->default(0);
            $table->bigInteger('object_id')->unsigned()->default(0);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('message');
        Schema::dropIfExists('message_read');
    }
}
